package lambdademo;

import java.util.ArrayList;
import java.util.function.Consumer;

public class Test2 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();

        list.add("zhangsan");
        list.add("lisi");
        list.add("wangwu");

        list.forEach(s -> System.out.print(s + " "));
    }
    public static void main1(String[] args) {
        ArrayList<String> list = new ArrayList<>();

        list.add("zhangsan");
        list.add("lisi");
        list.add("wangwu");

        list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.print(s + " ");
            }
        });
    }
}
